/**
 * Definition for a Node.
 * type Node struct {
 *     Val int
 *     Children []*Node
 * }
 */

func levelOrder(root *Node) [][]int {
    res := [][]int{}
    if root == nil {
        return res
    }

    queue := list.New()
    queue.PushBack(root)

    tempArr := []int{}

    for queue.Len() > 0 {
        length := queue.Len()

        for i:=0; i<length; i++ {
            node := queue.Remove(queue.Front()).(*Node)
            tempArr = append(tempArr, node.Val)
            for j:=0; j<len(node.Children); j++ {
                queue.PushBack(node.Children[j])
            }
        }
        res = append(res, tempArr)
        tempArr = []int{}
    }
    return res
}